import { getUserByDeptIdApi } from "@/api/common";
import { reactive, ref } from "vue";

export default function InitHook() {
  const formState = reactive<Partial<DepartmentPersonnel.AddUserForm>>({
    managerId: undefined
  });
  const formDataRef = ref<any>(null);
  const usertOpts = ref<Array<Base.GeneraDataType>>([]);
  const getAllUser = (id: string) => {
    return getUserByDeptIdApi(id).then((res: any) => {
      const { code, data } = res;
      if (code === 200) {
        usertOpts.value = data || [];
      }
    });
  };
  return {
    formState,
    formDataRef,
    usertOpts,
    getAllUser
  };
}
